import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class FloorLayer extends StatelessWidget {
  final String titleSrc;
  final List floorGoodsList;

  FloorLayer({Key key, this.titleSrc, this.floorGoodsList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        FloorTitle(pictureUrl: this.titleSrc),
        FloorContent(floorGoodsList: this.floorGoodsList)
      ],
    );
  }
}

class FloorTitle extends StatelessWidget {
  final String pictureUrl;

  FloorTitle({Key key, this.pictureUrl}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child: Image.network(this.pictureUrl, fit: BoxFit.cover),
    );
  }
}

class FloorContent extends StatelessWidget {
  final List floorGoodsList;

  FloorContent({Key key, this.floorGoodsList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[this._firstRow(), this._otherGoods()],
      ),
    );
  }

  Widget _firstRow() {
    return Row(
      children: <Widget>[
        this._goodItem(this.floorGoodsList[0]["image"]),
        Column(
          children: <Widget>[
            this._goodItem(this.floorGoodsList[1]["image"]),
            this._goodItem(this.floorGoodsList[2]["image"])
          ],
        ),
      ],
    );
  }

  Widget _goodItem(String src) {
    return Container(
      child: InkWell(
        onTap: () {
          print("点击了楼层商品");
        },
        child: Container(
          width: ScreenUtil().setWidth(750 / 2),
          child: Image.network(src, fit: BoxFit.cover),
        ),
      ),
    );
  }

  Widget _otherGoods() {
    return Row(
      children: <Widget>[
        this._goodItem(this.floorGoodsList[3]["image"]),
        this._goodItem(this.floorGoodsList[4]["image"])
      ],
    );
  }
}
